home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 111_01 / io.c < prev    next >
Text File  |  1985-08-19  |  896b  |  51 lines

  1. /*
  2. HEADER:        ;
  3. TITLE:        Squeezer;
  4. DESCRIPTION:    "Auxiliary file for the SQ.C and USQ.C package.";
  5. SYSTEM:        CP/M-80;
  6. FILENAME:    IO.C;
  7. AUTHORS:    Dick Greenlaw;
  8. COMPILERS:    BDS C;
  9. */
  10. #include <bdscio.h>
  11. #include <dio.h>
  12. #include "sqcom.h"
  13. #include "sq.h"
  14. #define STDOUT     4    /* console only (error) stream */
  15.  
  16. /* Get next byte from file and update checksum */
  17.  
  18. int
  19. getc_crc(ib)
  20. struct _buf *ib;
  21. {
  22.     int c;
  23.  
  24.     c = getc(ib);
  25.     if(c != EOF)
  26.         crc += c;    /* checksum */
  27.     return c;
  28. }
  29.  
  30. /* Output functions with error reporting */
  31.  
  32. putce(c, iob)
  33. int c;
  34. struct _buf *iob;
  35. {
  36.     if(putc(c, iob) == ERROR) {
  37.         fprintf(STDOUT, "Write error in putc()\n");
  38.         exit(1);
  39.     }
  40. }
  41.  
  42. putwe(w, iob)
  43. int w;
  44. struct _buf *iob;
  45. {
  46.     if(putw(w, iob) != w) {
  47.         fprintf(STDOUT,"Write error in putw()\n");
  48.         exit(1);
  49.     }
  50. }
  51.